package org.example.news_check.Controller;

import org.example.news_check.Pojo.newsHistory;
import org.example.news_check.Service.newsHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/news/history")
    public class newsHistoryController {
        @Autowired
        private  newsHistoryService newsHistoryService;



        @PostMapping("/save")//存储浏览记录，根据用户id和页面url
        public void save(@RequestParam Integer userId, @RequestParam String pageUrl) {
            newsHistoryService.save(userId, pageUrl);
        }

        @GetMapping("/{userId}")//根据用户id查询浏览记录
        public List<newsHistory> findByUserId(@PathVariable Integer userId) {
            return newsHistoryService.findByUserId(userId);
        }
    }


